<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="u" uri="/iuie-tag"%>
<%@ taglib prefix="sys" uri="/sys-tag" %>
<%@ taglib prefix="lui" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>开发工具箱</title>
</head>
<lui:context/>
<u:View basePath="/res-datum/development" userJS="developmentTool" userCSS="developmentTool" delayLoadJs="false">
<body>
<lui:boards className="m-fixed">
	<sys:dropCodeSet codeTypes="mybatisVersion,db,dataSetOption" id="codeSet"/>
	<lui:board width="38%" boardTitle="表实例">
		<form id="userTableFrm">
			<div class="form-group row m-narrow">
			    <div class="col-sm-6 col-md-6">
			        <div class="input-group">
						<label for="projectId" class="input-group-addon">项目</label>
						<lui:ajax url="${ctx }/datum/devProj/find/all" id="findAllProjectAjax" autoSend="true" async="false"
							respDataKey="projects"/>
						<lui:dropList id="projectId" name="projectId" textDefine="cnProjectName" valueDefine="id" 
							className="form-control m-input" showSelectAll="true" dropValues="projects" handleRowData="DevelopmentToolPage.handleRowData"
							showSelectName="请选择"/>
					</div>
			    </div>
			    <div class="col-sm-6 col-md-6">
			        <div class="input-group">
						<label for="tableName" class="input-group-addon">表名</label>
						<input name="tableName" id="tableName" type="text" class="form-control">
					</div>
			    </div>
			</div>
			<div class="form-horizontal">
				<div class="col-sm-6 col-md-6">
					<div class="form-group m-narrow">
				    	<div class="btn-group">
						    <button class="btn btn-default m-btn" type="reset">重置</button>
						    <button class="btn btn-success m-btn" type="button" onclick="DevelopmentToolPage.addTable()">新增</button>
						    <button class="btn btn-primary m-btn" type="button" onclick="DevelopmentToolPage.queryByCondition()">查询</button>
						</div>
				    </div>
				</div>
			</div>
			<u:dropListView id="dropView_oper">
			    <u:dropView name="deleteTable" template="delete" onClick="DevelopmentToolPage.deleteTable" title="删除表信息"/>
			    <u:dropView name="updateTable" template="edit" onClick="DevelopmentToolPage.updateTable" title="修改表信息"/>
			</u:dropListView>
			<u:dataSet id="userTableSet" idField="id">
			    <u:dataField display="ID" name="id" sort="false" visiable="false"/>
				<u:dataField display="项目名" name="projectName" sort="false" width="90px" align="left"/>
				<u:dataField display="表英文名" name="enTableName" sort="false" width="140px" align="left"/>
				<u:dataField display="表中文名" name="cnTableName" sort="false" width="140px" align="left"/>
				<u:dataField display="类名" name="className" sort="false" width="80px" visiable="false"/>
				<u:dataField display="备注" name="remark" sort="false" visiable="false"/>
				<u:dataField display="创建者姓名" name="creatorName" sort="false" width="60px" visiable="false"/>
				<u:dataField display="创建者账号" name="creatorId" sort="false" visiable="false"/>
				<u:dataField display="创建时间" name="createTime" sort="false" visiable="false"/>
			    <u:dataField name="oper" dropView="dropView_oper" display="操作" width="50px"/>
			</u:dataSet>
			<!-- 获取表实例列表ajax -->
			<lui:ajax id="findUserTableAjax" url="${ctx }/datum/development/find/page" formQuery="#userTableFrm"/>
			<lui:ajax id="deleteTableStructureByIdAjax" url="${ctx }/datum/development/delete/id/" onSuccess="DevelopmentToolPage.deleteTableStructureSucc"/>
			<lui:datatable id="userTableDatatable" ajax="findUserTableAjax" pagination="userTablePagination" dataset="userTableSet" tip="true" 
				multiple="false" cutLine="true" onItemClick="DevelopmentToolPage.onUserTableItemClick" afterReady="DevelopmentToolPage.afterReady"/>
			<lui:pagination datatable="userTableDatatable" id="userTablePagination" pageSize="15" pageChoice="15" showPageChoice="false"/>
		</form>
	</lui:board>
	<lui:board width="62%" boardTitle="详情">
		<fieldset class="m-narrow">
			<legend>基本信息</legend>
			<form id="tableInfoFrm" class="m-cust">
				<table class="m-composing m-full-width">
					<tr>
						<td>表英文名：</td>
						<td colspan="2"><input name="enTableName" class="m-input" readonly="readonly" style="width: 100%"></td>
						<td>类名：</td>
						<td colspan="2"><input name="className" class="m-input" readonly="readonly" style="width: 100%"></td>
					</tr>
					<tr>
						<td>表中文名：</td>
						<td><input name="cnTableName" class="m-input" readonly="readonly"></td>
						<td>创建者账号：</td>
						<td><input name="creatorId" class="m-input" readonly="readonly"></td>
						<td>创建者姓名：</td>
						<td><input name="creatorName" class="m-input" readonly="readonly"></td>
					</tr>
					<tr>
						<td>创建时间：</td>
						<td><input name="createTime" class="m-input" readonly="readonly"></td>
						<td>变更历史</td>
						<td colspan="3"><a href='javascript:void(0);' onclick="DevelopmentToolPage.viewHistory()" class="t-viewHistory">查看</a></td>
					</tr>
					<tr>
						<td>注释：</td>
						<td colspan="5"><textarea name="remark" class="form-control" disabled="disabled" rows="2"></textarea></td>
					</tr>
				</table>
			</form>
		</fieldset>
		<fieldset class="m-narrow">
			<legend>字段信息</legend>
			<form id="tableFieldInfoFrm" class="m-cust">
				<div class="form-horizontal">
					<div class="form-group">
						<div class="col-md-12 col-sm-12">
							<div class="btn-group" id="buttonGro">
								<button type="button" class="btn btn-info" onclick="DevelopmentToolPage.addField()"><i class='fa fa-fw fa-plus'></i>新增</button>
								<button type="button" class="btn btn-success" onclick="DevelopmentToolPage.openBatchAddDialog()"><i class='fa fa-fw fa-bolt'></i>批量新增</button>
								<button type="button" class="btn btn-primary" onclick="DevelopmentToolPage.queryFields()"><i class='fa fa-fw fa-search'></i>查询</button>
							</div>
						</div>
					</div>
				</div>
				<u:dropListView id="dropFieldView_oper">
				    <u:dropView name="deleteField" template="delete" onClick="DevelopmentToolPage.deleteField" title="删除字段"/>
				    <u:dropView name="updateField" template="edit" onClick="DevelopmentToolPage.updateField" title="修改字段"/>
				</u:dropListView>
				<u:dataSet id="tableFieldSet" idField="id">
				    <u:dataField display="ID" name="id" sort="false" visiable="false"/>
					<u:dataField display="表ID" name="tableId" sort="false" visiable="false"/>
					<u:dataField display="字段名称" name="fieldName" sort="false" width="120px" align="left"/>
					<u:dataField display="字段类型" name="fieldType" sort="false" align="left" width="80px"/>
					<u:dataField display="长度" name="fieldLength" sort="false" width="60px" align="left"/>
					<u:dataField display="DISPLAY" name="display" align="left" sort="false" width="98px" />
					<u:dataField display="注释" name="comment" align="left" sort="false" width="120px"/>
					<u:dataField display="主键" name="isPrimaryKey" sort="false" width="40px"/>
					<u:dataField display="非空" name="allowNull" sort="false" width="40px"/>
					<u:dataField display="用于查询" name="doQuery" sort="false" width="40px"/>
					<u:dataField display="模糊查询" name="queryMode" sort="false" width="40px"/>
					<u:dataField display="用于更新" name="doUpdate" 	sort="false" width="40px"/>
					<u:dataField name="oper" dropView="dropFieldView_oper" display="操作" width="60px"/>
				</u:dataSet>
				<input name="tableId" hidden="hidden">
				<!-- 获取表字段列表ajax -->
				<lui:ajax id="findTableFieldAjax" url="${ctx }/datum/development/find/fields/tableId" formQuery="#tableFieldInfoFrm"
					formSubmit="true"/>
				<!-- 删除字段ajax -->
				<lui:ajax id="deleteFieldAjax" url="${ctx }/datum/development/delete/field/" type="post"
					onSuccess="DevelopmentToolPage.onDeleteFieldSucc"/>
				<lui:ajax id="updateDoQueryAjax" silent="true" url="${ctx }/datum/development/update/doQuery/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess"/>
				<lui:ajax id="updateQueryModeAjax" silent="true" url="${ctx }/datum/development/update/queryMode/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess"/>
				<lui:ajax id="updateDoUpdateAjax" silent="true" url="${ctx }/datum/development/update/doUpdate/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess"/>
				<lui:ajax id="updateAllNullAjax" silent="true" url="${ctx }/datum/development/update/allowNull/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess"/>
				<lui:ajax id="updateIsPrimaryKeyAjax" silent="true" url="${ctx }/datum/development/update/isPrimaryKey/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess"/>
				<lui:ajax id="updateDisplayAjax" silent="true" url="${ctx }/datum/development/update/display/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess" contentType="application/x-www-form-urlencoded"/>
				<lui:ajax id="updateCommentAjax" silent="true" url="${ctx }/datum/development/update/comment/" type="post"
					onSuccess="DevelopmentToolPage.onUpdateSuccess" contentType="application/x-www-form-urlencoded"/>
				<lui:datatable id="tableFieldDatatable" ajax="findTableFieldAjax" sortable="true" dataset="tableFieldSet" 
					checkable="false" multiple="false" cutLine="true" tip="true"
					onRenderItem="DevelopmentToolPage.onRenderItem"/>
			</form>
		</fieldset>
		<fieldset class="m-narrow">
			<legend>转化</legend>
			<ul class='m-fixed-tabset' id="mtabset" data-container='#mcontainer'>
			    <li data-active='true' data-target='packageFrm'><a>打包</a></li>
			    <li data-target='toJavaBeanFrm'><a>转JavaBean</a></li>
			    <li data-target='toResultMapFrmContainer'><a>转ResultMap</a></li>
			    <li data-target='toDataSetFrm'><a>转DataSet</a></li>
			    <li data-target='toCreateSQLFrm'><a>转SQL(建表)</a></li>
			</ul>
			<ul class='m-fixed-tabset-container' id="mcontainer" style="min-height: 513px;">
			    <li data-id="packageFrm">
			    	<form id="packageFrm" class='m-cust' style="display:none;">
       				</form>
			    </li>
			    <li data-id="toJavaBeanFrm">
			    	<form id="toJavaBeanFrm" class='m-cust' style="display:none; margin-top: 10px;">
				    	<div class="form-group m-narrow" style='display:-webkit-box;'>
						    <div class="col-sm-6 col-md-6 col-xs-6">
						    	<div class="input-group">
								    <label for="className" class="input-group-addon">类名</label>
								    <input name="className" id="className" type="text" class="form-control">
								</div>
						    </div>
						    <div class="col-sm-6 col-md-6 col-xs-6">
						    	<button class="btn btn-primary m-btn" type="button" onclick="DevelopmentToolPage.transferToJavaBean()">转化</button>
						    	<button class="btn btn-info m-btn" type="button" onclick="DevelopmentToolPage.copyJavaBean()">复制</button>
						    </div>
						</div>
						<div class="form-group m-narrow"  style='display:-webkit-box;'>
							<div class="col-sm-12 col-md-12 col-xs-12">
							</div>
						</div>
						<div class="form-group m-narrow"  style='display:-webkit-box;'>
							<div class="col-sm-12 col-md-12 col-xs-12">
								<textarea rows="22" cols="" class="form-control" name="result" readonly="readonly" ></textarea>
							</div>
						</div>
						<lui:ajax id="transToJavaBeanAjax" url="${ctx }/datum/development/transTo/javaBean/" type='post' formQuery="#toJavaBeanFrm"
							formSubmit="true" onSuccess="DevelopmentToolPage.onTransToJavaBeanSucc" contentType="application/x-www-form-urlencoded" />
					</form>
			    </li>
			    <li data-id="toResultMapFrmContainer">
			    	<div id="toResultMapFrmContainer" class='m-cust' style="display:none; margin-top: 10px;">
			    		<form id="toResultMapFrm">
				    		<div class="form-group m-narrow" style='display:-webkit-box;'>
							    <div class="col-sm-6 col-md-6 col-xs-6">
							    	<div class="input-group">
									    <label for="mybatisVersion" class="input-group-addon">mybatis版本</label>
							    		<lui:dropList id="mybatisVersion" name="mybatisVersion" dropValues="codeSet.mybatisVersion" className="form-control m-input"
							    			textDefine="codeInfoValue" />
									</div>
							    </div>
							    <div class="col-sm-6 col-md-6 col-xs-6">
							    </div>
							</div>
							<fieldset class="m-narrow">
								<legend>属性</legend>
								<div class="form-group m-narrow"  style='display:-webkit-box;'>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input id='selectAll' name="selectAll" type='checkbox' class="m-single-checkbox" 
												onchange="DevelopmentToolPage.selectAll(this)" >
											<label for="selectAll" class='m-label m-normal-font-weight'>选择所有</label>
										</div>
									</div>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='findByCondition' data-cbelement id='findByCondition' type='checkbox' 
												onchange="DevelopmentToolPage.stateChanged(this)" class="m-single-checkbox" value='1'>
											<label for="findByCondition" class='m-label m-normal-font-weight'>findByCondition</label>
										</div>
									</div>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='findById' data-cbelement id='findById' type='checkbox' 
												onchange="DevelopmentToolPage.stateChanged(this)" class="m-single-checkbox" value='1'>
											<label for="findById" class='m-label m-normal-font-weight'>findById</label>
										</div>
									</div>
									
								</div>
								<div class="form-group m-narrow"  style='display:-webkit-box;'>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='addOne' data-cbelement id='addOne' type='checkbox' 
												onchange="DevelopmentToolPage.stateChanged(this)" class="m-single-checkbox" value='1'>
											<label for="addOne" class='m-label m-normal-font-weight'>addOne</label>
										</div>
									</div>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='updateOne' data-cbelement id='updateOne' onchange="DevelopmentToolPage.stateChanged(this)" 
												type='checkbox' class="m-single-checkbox" value='1'>
											<label for="updateOne" class='m-label m-normal-font-weight'>updateOne</label>
										</div>
									</div>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='deleteById' data-cbelement id='deleteById' onchange="DevelopmentToolPage.stateChanged(this)" 
												type='checkbox' class="m-single-checkbox" value='1'>
											<label for="deleteById" class='m-label m-normal-font-weight'>deleteById</label>
										</div>
									</div>
								</div>
								<div class="form-group m-narrow"  style='display:-webkit-box;'>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='batchAdd' data-cbelement id='batchAdd' onchange="DevelopmentToolPage.stateChanged(this)" 
												type='checkbox' class="m-single-checkbox" value='1'>
											<label for="batchAdd" class='m-label m-normal-font-weight'>batchAdd</label>
										</div>
									</div>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='batchUpdate' data-cbelement id='batchUpdate' onchange="DevelopmentToolPage.stateChanged(this)" 
												type='checkbox' class="m-single-checkbox" value='1'>
											<label for="batchUpdate" class='m-label m-normal-font-weight'>batchUpdate</label>
										</div>
									</div>
									<div class="col-sm-4 col-md-4 col-xs-4">
										<div>
											<input name='batchDelete' data-cbelement id='batchDelete' onchange="DevelopmentToolPage.stateChanged(this)" 
												type='checkbox' class="m-single-checkbox" value='1'>
											<label for="batchDelete" class='m-label m-normal-font-weight'>batchDelete</label>
										</div>
									</div>
								</div>
							</fieldset>
							<div class="form-group m-narrow"  style='display:-webkit-box;'>
								<div class="col-sm-12 col-md-12 col-xs-12">
							    	<button class="btn btn-primary m-btn" type="button" onclick="DevelopmentToolPage.transToResultMap()">转化</button>
							    	<button class="btn btn-info m-btn" type="button" onclick="DevelopmentToolPage.copyResultMap()">复制</button>
								</div>
							</div>
							<div class="form-group m-narrow"  style='display:-webkit-box;'>
								<div class="col-sm-12 col-md-12 col-xs-12">
									<textarea rows="22" cols="" class="form-control" name="result" readonly="readonly" ></textarea>
								</div>
							</div>
				    		<lui:ajax id="transToResultMapAjax" url="${ctx }/datum/development/transTo/resultMap/" type='post' formQuery="#toResultMapFrm"
								formSubmit="true" onSuccess="DevelopmentToolPage.onTransToResultMapSucc" contentType="application/x-www-form-urlencoded" />
	       				</form>
	       				<form id="toJavaMapperFrm">
	       					<div class="form-group m-narrow"  style='display:-webkit-box;'>
	       						<div class="col-sm-12 col-md-12 col-xs-12">
	       							<hr>
	       							转JavaMapper
	       						</div>
	       					</div>
	       					<div class="form-group m-narrow"  style='display:-webkit-box;'>
								<div class="col-sm-12 col-md-12 col-xs-12">
							    	<button class="btn btn-primary m-btn" type="button" onclick="DevelopmentToolPage.transToJavaMapper()">转化</button>
							    	<button class="btn btn-info m-btn" type="button" onclick="DevelopmentToolPage.copyJavaMapper()">复制</button>
								</div>
							</div>
							<div class="form-group m-narrow"  style='display:-webkit-box;'>
								<div class="col-sm-12 col-md-12 col-xs-12">
									<textarea rows="22" cols="" class="form-control" name="result" readonly="readonly" ></textarea>
								</div>
							</div>
	       					<lui:ajax id="transToJavaMapperAjax" url="${ctx }/datum/development/transTo/javaMapper/" type='post' formQuery="#toResultMapFrm"
								formSubmit="true" onSuccess="DevelopmentToolPage.onTransToJavaMapperSucc" contentType="application/x-www-form-urlencoded" />
	       				</form>
       				</div>
			    </li>
			    <li data-id="toDataSetFrm">
			    	<form id="toDataSetFrm" style="display:none; margin-top: 10px;">
			    		<div class="form-group m-narrow"  style='display:-webkit-box;'>
							<div class="col-sm-6 col-md-6 col-xs-6">
								<lui:dropList id="tag" name="tag" className="form-control m-input" dropValues="codeSet.dataSetOption" />
							</div>
							<div class="col-sm-6 col-md-6 col-xs-6">
						    	<button class="btn btn-primary m-btn" type="button" onclick="DevelopmentToolPage.transToDataSet()">转化</button>
						    	<button class="btn btn-info m-btn" type="button" onclick="DevelopmentToolPage.copyToDataSet()">复制</button>
							</div>
						</div>
						<div class="form-group m-narrow"  style='display:-webkit-box;'>
							<div class="col-sm-12 col-md-12 col-xs-12">
								<textarea rows="22" cols="" class="form-control" name="result" readonly="readonly" ></textarea>
							</div>
						</div>
						<lui:ajax id="transToDataSetAjax" url="${ctx }/datum/development/transTo/dataSet/" type='post' formQuery="#toDataSetFrm"
							formSubmit="true" onSuccess="DevelopmentToolPage.onTransToDataSetSucc" contentType="application/x-www-form-urlencoded" />
        			</form>
			    </li>
			    <li data-id="toCreateSQLFrm">
			    	<form id="toCreateSQLFrm" style="display:none; margin-top: 10px;">
			    		<div class="form-group m-narrow"  style='display:-webkit-box;'>
							<div class="col-sm-6 col-md-6 col-xs-6">
								<lui:dropList id="db" name="db" className="form-control m-input" dropValues="codeSet.db" showSelectAll="true" showSelectName="请选择"/>
							</div>
							<div class="col-sm-6 col-md-6 col-xs-6">
						    	<button class="btn btn-primary m-btn" type="button" onclick="DevelopmentToolPage.transToCreateSQL()">转化</button>
						    	<button class="btn btn-info m-btn" type="button" onclick="DevelopmentToolPage.copyCreateSQL()">复制</button>
							</div>
						</div>
						<div class="form-group m-narrow"  style='display:-webkit-box;'>
							<div class="col-sm-12 col-md-12 col-xs-12">
								<textarea rows="22" cols="" class="form-control" name="result" readonly="readonly" ></textarea>
							</div>
						</div>
						<lui:ajax id="transToCreateSQLAjax" url="${ctx }/datum/development/transTo/tableCreateSql/" type='post' formQuery="#toCreateSQLFrm"
							formSubmit="true" onSuccess="DevelopmentToolPage.onTransToCreateSQLSucc" contentType="application/x-www-form-urlencoded" />
			    	</form>
			    </li>
			</ul>
		</fieldset>
	</lui:board>
</lui:boards>
</body>
</u:View>
</html>